package iterator;

public class AscendIterator implements Iterator {
    StudentGroup studentGroup;
    int index;

    public AscendIterator(StudentGroup studentGroup) {
        this.studentGroup = studentGroup;
        index = 0;
    }

    @Override
    public boolean hasNext() {
        return studentGroup != null
                && index < studentGroup.getSize();
    }

    @Override
    public Object getNext() {
        if (!hasNext()) {
            return null;
        }
        return studentGroup.get(index++);
    }
}
